package com.greystripe.sdk;

import android.content.Context;
import android.hardware.Camera;
import android.hardware.Camera.Parameters;
import android.view.SurfaceHolder;
import android.view.SurfaceHolder.Callback;
import android.view.SurfaceView;
import java.io.IOException;
import java.util.List;

public class CameraPreview extends SurfaceView
  implements SurfaceHolder.Callback
{
  private SurfaceHolder a;
  private Camera b;

  public CameraPreview(Context paramContext, Camera paramCamera)
  {
    super(paramContext);
    this.b = paramCamera;
    this.a = getHolder();
    this.a.addCallback(this);
    this.a.setType(3);
  }

  final void a()
  {
    if (this.b != null);
    try
    {
      this.b.autoFocus(new ar(this));
      return;
    }
    catch (RuntimeException localRuntimeException)
    {
      bd.b("Camera released already", new Object[0]);
    }
  }

  public void surfaceChanged(SurfaceHolder paramSurfaceHolder, int paramInt1, int paramInt2, int paramInt3)
  {
    if (this.a.getSurface() == null)
      return;
    try
    {
      this.b.stopPreview();
      try
      {
        this.b.setPreviewDisplay(this.a);
        this.b.startPreview();
        return;
      }
      catch (Exception localException2)
      {
        Object[] arrayOfObject = new Object[1];
        arrayOfObject[0] = ("Error starting camera preview: " + localException2.getMessage());
        bd.b("greystripe", arrayOfObject);
        return;
      }
    }
    catch (Exception localException1)
    {
      while (true)
        localException1.printStackTrace();
    }
  }

  public void surfaceCreated(SurfaceHolder paramSurfaceHolder)
  {
    try
    {
      this.b.setPreviewDisplay(paramSurfaceHolder);
      Camera.Parameters localParameters = this.b.getParameters();
      if (localParameters.getSupportedFocusModes().contains("auto"))
      {
        bd.b("contains auto focus", new Object[0]);
        localParameters.setFocusMode("auto");
      }
      while (true)
      {
        this.b.setParameters(localParameters);
        this.b.startPreview();
        return;
        bd.b("doesn't contain auto focus", new Object[0]);
      }
    }
    catch (IOException localIOException)
    {
      Object[] arrayOfObject = new Object[1];
      arrayOfObject[0] = ("Error setting camera preview: " + localIOException.getMessage());
      bd.b("greystripe", arrayOfObject);
    }
  }

  public void surfaceDestroyed(SurfaceHolder paramSurfaceHolder)
  {
    bd.b("stop preview and free camera", new Object[0]);
    if (this.b != null)
    {
      this.b.stopPreview();
      this.b.release();
      this.b = null;
    }
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.greystripe.sdk.CameraPreview
 * JD-Core Version:    0.6.2
 */